<template>
  <router-link :to="'/detail/' + newsItem.id" class="news-item">
    <div class="left">
      <h3>{{newsItem.title}}</h3>
      <div class="info">
        <span class="from">{{newsItem.from}}</span>
        <span class="date">{{newsItem.time}}</span>
      </div>
    </div>
    <div class="right">
      <img :src="imgs[newsItem.imgIdx]" alt="">
    </div>
  </router-link>
</template>

<script>
import img1 from '@/assets/img/1.jpg'
import img2 from '@/assets/img/2.jpg'
import img3 from '@/assets/img/3.png'
import img4 from '@/assets/img/4.jpg'
import img5 from '@/assets/img/5.jpg'
export default{
  name:'NewsItem',
  props:['newsItem'],
  data(){
    return {
      imgs: [img1, img2, img3, img4, img5]
    }
  }
}
</script>

<style lang="less" scoped>
.news-item{
  text-decoration: none;
  color: #000;
  display: flex;
  border-bottom: 1px solid #f8f8f8;
  padding: 10px 2%;
  .left{
    width: 70%;
    height: 79px;
    position: relative;
    h3{
      font-size: 16px;
      font-weight: 500;
    }
    .info{
        position: absolute;
        bottom: 0;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        font-size: 12px;
        color: #888; 
    }
  }
  .right{
    flex: 1;
    margin-left: 10px;
    img{
      height: 64px;
      border-radius: 5px;
    }
  }
}
</style>
